const fs = require('fs');
const path = require('path');
const koaBody = require('koa-body');
module.exports = (app) => {
    //普通路由
    const files = fs.readdirSync(path.join(__dirname,'/route'));
    files.forEach((moduleName,index)=>{
        const mdu = require(path.join(__dirname,`/route/${moduleName}`));
        app.use(mdu.routes(), mdu.allowedMethods());
    });
    // //文件上传的路由
    app.use(koaBody({ multipart: true }));
    const uploadFiles = fs.readdirSync(path.join(__dirname,'/uploadRoute'));
    uploadFiles.forEach((moduleName,index)=>{
        const mdu = require(path.join(__dirname,`/uploadRoute/${moduleName}`));
        app.use(mdu.routes(), mdu.allowedMethods());
    });
};